package disanzuoye;

import java.util.Scanner;

public class workPro {
    public static void main(String[] args) {
        int[]arr=new int[5];
        workPro.inPut(arr);
        workPro.paixu(arr);
        workPro.OutPut(arr);
    }
    public static void inPut(int[] arr){
        for (int a=0;a<5;a++){
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入第"+ (a+1) +"个数");
            arr [a] = scanner.nextInt();
        }
    }
    public static void OutPut(int[] arr){
        System.out.println("排序后的顺序为：");
         for (int i = 0; i < 5; i++) {
             System.out.print(arr[i]+" ");
        }
        System.out.println(" ");
    }
    public static void paixu(int[]arr) {
        int x, r;
        for (int i = 0; i < arr.length - 1; i++) {
            x = i;
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[j] < arr[x]) {
                    x = j;
                }
            }
            if (x != i) {
                r = arr[x];
                arr[x] = arr[i];
                arr[i] = r;
            }
        }
    }
}
